var paymentUtils = {
    dynamicChosen: function (modelId ,id, data,key,value) {
        var $e = com.focusPage('#' + id);
        $e.html("");
        $e.val("");
        $('<option value="">&nbsp;</option>').appendTo($e);
        $.each(data, function (i, v) {
            $('<option value="' +v[key]+ '">' + v[value]+ '</option>').appendTo($e);
        });

        $e.chosen({allow_single_deselect: true});
        com.focusPage('#' + id + '_chosen input').bind("input", function () {
            var val = $(this).val();
            if (val != "") {
                deployChosen(val);
            } else {
                deployChosen();
            }
        });

        com.focusPage('#' + id + '_chosen').bind('click', function () {
            var val = $('#' + id + '_chosen a span').html();
            if ('' + val + '' == '&nbsp;') {
                deployChosen();
            }
        });
        var deployChosen = function (val) {
            var html = '<option value="">&nbsp;</option>';
            var kv = data;
            var length = kv.length;
            for (var i = 0; i < length; i++) {

                var _ = kv[i];
                if (val) {
                    if (_[value].match(val)) {
                        html += '<option value="'+_[key]+ '">' + _[value] + '</option>';
                    }
                } else {
                    html += '<option value="'+_[key]+'">' + _[value]+ '</option>';
                }
            }
            $e.html(html).trigger("chosen:updated");
        };

        com.focusPage('#' + id + '_chosen').css('min-width','50%').css('width','170px');

        com.focusPage('#' +modelId+' input').css('min-width','50%').css('width','170px');
    },
    EmptyChosen : function(id){
        com.focusPage('#' + id).val("");
        com.focusPage('#' + id + '_chosen a span').html("");
    }

};